package com.webflux.demo.modle;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.Persistable;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

/**
 * @Author RenPu
 * @Date 2023/5/23 11:06
 * @Version 1.0
 * @Description:
 **/

@Table("user")
@NoArgsConstructor
@AllArgsConstructor
@Data
public class User implements Persistable<Long> {
    @Id
    private Long userId;

    private String userName;

    private String userSex;

    private Integer updateCount;

    private Integer version;

    @Transient
    private boolean isNew;


    @Override
    public Long getId() {
        return null;
    }

    @Override
    @Transient
    public boolean isNew() {
         return this.isNew || userId == null;
    }

    public User setAsNew(){
        this.isNew = true;
        return this;
    }
}
